<html>
<head><meta charset="utf-8"><title>Program slicing in RA · t-compiler/rust-analyzer · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/index.html">t-compiler/rust-analyzer</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Program.20slicing.20in.20RA.html">Program slicing in RA</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="228018712"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Program%20slicing%20in%20RA/near/228018712" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Will Crichton <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Program.20slicing.20in.20RA.html#228018712">(Feb 27 2021 at 00:42)</a>:</h4>
<p>Hi everyone. I'm Will, a CS PhD student at Stanford. My research is about using psychological principles to improve programming tools.</p>
<p>I'm interested in building a <a href="https://en.wikipedia.org/wiki/Program_slicing">program slicer</a> for Rust integrated into rust-analyzer. The core concept is that you could click a variable and query for the set of operations that are needed to compute the variable. A simple conservative analysis would be to include any code that mutably borrows that variable.</p>
<p>In order to implement this strategy, I need access to borrow information. But from my understanding, RA doesn't implement borrow checking, only type checking. Would I need to fully reimplement the Rust borrow checker to get borrow information? Or put another way, is my only choice to build a separate plugin against rustc_private that could somehow be invoked by RA?</p>



<a name="228035922"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Program%20slicing%20in%20RA/near/228035922" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Program.20slicing.20in.20RA.html#228035922">(Feb 27 2021 at 05:47)</a>:</h4>
<p>I'm probably missing something, but do you actually need borrow checking? Mutable borrows are already expressed in the type system and for a correct program you don't need the borrow checker to evaluate it</p>



<a name="228045855"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Program%20slicing%20in%20RA/near/228045855" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Program.20slicing.20in.20RA.html#228045855">(Feb 27 2021 at 09:19)</a>:</h4>
<p>Yeah, I don't think you need full borrow checker here</p>



<a name="228045887"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Program%20slicing%20in%20RA/near/228045887" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Program.20slicing.20in.20RA.html#228045887">(Feb 27 2021 at 09:19)</a>:</h4>
<p>though, you might need control flow analysis, which we don't have either</p>



<a name="228045946"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Program%20slicing%20in%20RA/near/228045946" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Program.20slicing.20in.20RA.html#228045946">(Feb 27 2021 at 09:20)</a>:</h4>
<p>You might want to take a look at how we decide if we should underline the variable during highlighting: <a href="https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide/src/syntax_highlighting/highlight.rs#L333-L335">https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide/src/syntax_highlighting/highlight.rs#L333-L335</a></p>



<a name="228045954"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Program%20slicing%20in%20RA/near/228045954" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Program.20slicing.20in.20RA.html#228045954">(Feb 27 2021 at 09:20)</a>:</h4>
<p>The first approximation of a program slice would be the set of all expressions, where the variable is underined</p>



<a name="228046037"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Program%20slicing%20in%20RA/near/228046037" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Program.20slicing.20in.20RA.html#228046037">(Feb 27 2021 at 09:22)</a>:</h4>
<p><a href="/user_uploads/4715/Ua-_ezKB6cK3ZFV-RFLOvE8h/image.png">image.png</a></p>
<div class="message_inline_image"><a href="/user_uploads/4715/Ua-_ezKB6cK3ZFV-RFLOvE8h/image.png" title="image.png"><img src="/user_uploads/4715/Ua-_ezKB6cK3ZFV-RFLOvE8h/image.png"></a></div>



<a name="228046058"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Program%20slicing%20in%20RA/near/228046058" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Program.20slicing.20in.20RA.html#228046058">(Feb 27 2021 at 09:23)</a>:</h4>
<p>(we actually need to improme that to <em>not</em> underline the varible when it is used immutably)</p>



<a name="228062737"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Program%20slicing%20in%20RA/near/228062737" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Will Crichton <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Program.20slicing.20in.20RA.html#228062737">(Feb 27 2021 at 14:53)</a>:</h4>
<p><span class="user-mention" data-user-id="203546">@Laurențiu Nicola</span>  I think you need some kind of  borrow information. Here's a simple example:</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="kd">let</span><span class="w"> </span><span class="k">mut</span><span class="w"> </span><span class="n">x</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">1</span><span class="p">;</span><span class="w"></span>
<span class="kd">let</span><span class="w"> </span><span class="n">w</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="o">&amp;</span><span class="k">mut</span><span class="w"> </span><span class="n">x</span><span class="p">;</span><span class="w"></span>
<span class="o">*</span><span class="n">w</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">2</span><span class="p">;</span><span class="w"></span>
<span class="fm">println!</span><span class="p">(</span><span class="s">"{}"</span><span class="p">,</span><span class="w"> </span><span class="n">x</span><span class="p">);</span><span class="w"></span>
</code></pre></div>
<p>A program slicer needs to know that line 3 affects the value of <code>x</code>. Or at least, that <code>w</code> has a mutable borrow on <code>x</code>, and so mutations to <code>w</code> could affect <code>x</code>. </p>
<p>Right now, it's possible in RA to find all references to a variable. So I can identify that <code>x</code> is used on line 2. But the fact that <code>w</code> mutably borrows <code>x</code> is not computed.</p>
<p><span class="user-mention" data-user-id="133169">@matklad</span><del> can you explain when the highlighting you linked is activated? Can't seem to get underlining to appear in my own IDE.</del> Nevermind, it's because I was using a different theme :-) the underlining doesn't seem to show up on Solarized Light.</p>



<a name="228063618"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Program%20slicing%20in%20RA/near/228063618" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Program.20slicing.20in.20RA.html#228063618">(Feb 27 2021 at 15:10)</a>:</h4>
<p><span class="user-mention" data-user-id="265377">@Will Crichton</span> the IDE needs support for "semantic tokens" LSP feature, and the color scheme needs to have support for mutable token kind</p>



<a name="228063725"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Program%20slicing%20in%20RA/near/228063725" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Program.20slicing.20in.20RA.html#228063725">(Feb 27 2021 at 15:11)</a>:</h4>
<p>ah, I see now, that's a good example! Yeah, at the moment rust-analyzer can only say: "hey, in line <code>let w = &amp;mut x</code>, you are going to mutate <code>x</code>". It won't be able to infer that <code>*w = 2</code> is a specific mutation to x</p>



<a name="228063807"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Program%20slicing%20in%20RA/near/228063807" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Program.20slicing.20in.20RA.html#228063807">(Feb 27 2021 at 15:12)</a>:</h4>
<p>So yeah, if you need that level of precision, you either need to add borrow checker to rust-analyzer, or to build on top of <code>rustc</code></p>



<a name="228063840"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Program%20slicing%20in%20RA/near/228063840" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Program.20slicing.20in.20RA.html#228063840">(Feb 27 2021 at 15:13)</a>:</h4>
<p>What about mutating values through <code>Rc</code>?</p>



<a name="228063844"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Program%20slicing%20in%20RA/near/228063844" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Will Crichton <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Program.20slicing.20in.20RA.html#228063844">(Feb 27 2021 at 15:13)</a>:</h4>
<p><span class="user-mention" data-user-id="133169">@matklad</span>  Are there any features in RA that do round-trips to rustc? It's ok for now if the slicing takes a few seconds to run. I'm thinking that adding borrow checks to RA is probably too much for me right now.</p>
<p><span class="user-mention" data-user-id="203546">@Laurențiu Nicola</span> this analysis would definitely not be complete, ie won't work with interior mutability.</p>



<a name="228063897"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Program%20slicing%20in%20RA/near/228063897" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Program.20slicing.20in.20RA.html#228063897">(Feb 27 2021 at 15:14)</a>:</h4>
<p>No, not really, we are by design avoid calling into rustc</p>



<a name="228063969"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Program%20slicing%20in%20RA/near/228063969" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Will Crichton <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Program.20slicing.20in.20RA.html#228063969">(Feb 27 2021 at 15:15)</a>:</h4>
<p>: ' ( alright, well I'll shelve this idea for now and just implement a standalone analysis.</p>



<a name="228064036"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Program%20slicing%20in%20RA/near/228064036" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Program.20slicing.20in.20RA.html#228064036">(Feb 27 2021 at 15:16)</a>:</h4>
<p>Would <code>polonius</code> help with this?</p>



<a name="228064135"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Program%20slicing%20in%20RA/near/228064135" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Will Crichton <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Program.20slicing.20in.20RA.html#228064135">(Feb 27 2021 at 15:18)</a>:</h4>
<p>Hmm possibly. If I could drop-in a borrow checker and just implement the initial fact generation, that seems like less works. Great point, I will check it out.</p>



<a name="228064157"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Program%20slicing%20in%20RA/near/228064157" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Program.20slicing.20in.20RA.html#228064157">(Feb 27 2021 at 15:19)</a>:</h4>
<p>But I don't think it's seen much work lately</p>



<a name="228064183"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Program%20slicing%20in%20RA/near/228064183" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Program.20slicing.20in.20RA.html#228064183">(Feb 27 2021 at 15:19)</a>:</h4>
<p>I don't think Polonius is complete enough to be useful here</p>



<a name="228064299"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Program%20slicing%20in%20RA/near/228064299" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Will Crichton <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Program.20slicing.20in.20RA.html#228064299">(Feb 27 2021 at 15:21)</a>:</h4>
<p>I will add -- as a research project, my initial goal is not to build the most robust program slicer possible.  Rather, I want to find situations in everyday Rust development that would benefit from slicing. So long as the tool works for a few key cases, that's a good start. </p>
<p>After this phase, if slicing seems to be really useful, then we could figure out a longer-term integration strategy.</p>



<a name="228064690"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Program%20slicing%20in%20RA/near/228064690" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Program.20slicing.20in.20RA.html#228064690">(Feb 27 2021 at 15:28)</a>:</h4>
<p>If that doesn't pan out, can I interest you in a test case minimization tool? <span aria-label="joy cat" class="emoji emoji-1f639" role="img" title="joy cat">:joy_cat:</span></p>



<a name="228067227"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Program%20slicing%20in%20RA/near/228067227" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vytautas Astrauskas [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Program.20slicing.20in.20RA.html#228067227">(Feb 27 2021 at 16:15)</a>:</h4>
<p>A quick question: does RA have precise information about lifetime constraints? For example, in the following snippet:</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="kd">let</span><span class="w"> </span><span class="k">mut</span><span class="w"> </span><span class="n">x</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="fm">vec!</span><span class="p">[</span><span class="o">..</span><span class="p">.];</span><span class="w"></span>
<span class="n">r</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="o">&amp;</span><span class="k">mut</span><span class="w"> </span><span class="n">x</span><span class="p">;</span><span class="w"></span>
<span class="n">r</span><span class="p">.</span><span class="n">push</span><span class="p">(</span><span class="o">&amp;</span><span class="k">mut</span><span class="w"> </span><span class="n">y</span><span class="p">);</span><span class="w"></span>
</code></pre></div>
<p>The last statement would add a constraint that the anonymous lifetime associated with <code>y</code> should outlive the anonymous lifetime associated with <code>r</code>. As far as I know, Polonius is missing this information and it is critical.</p>



<a name="228067309"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Program%20slicing%20in%20RA/near/228067309" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vytautas Astrauskas [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Program.20slicing.20in.20RA.html#228067309">(Feb 27 2021 at 16:17)</a>:</h4>
<p>By “missing” I mean that this information is computed by Rustc and given to Polonius as input.</p>



<a name="228067323"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Program%20slicing%20in%20RA/near/228067323" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Program.20slicing.20in.20RA.html#228067323">(Feb 27 2021 at 16:17)</a>:</h4>
<p>r-a does not compute that at the moment</p>



<a name="228067324"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Program%20slicing%20in%20RA/near/228067324" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Program.20slicing.20in.20RA.html#228067324">(Feb 27 2021 at 16:17)</a>:</h4>
<p>no, rust-analyzer doesn't deal with lifetimes at all yet, basically. There's a large amount of plumbing that would need to be implemented before we can even start thinking about polonius integration</p>



<a name="228067400"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Program%20slicing%20in%20RA/near/228067400" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Program.20slicing.20in.20RA.html#228067400">(Feb 27 2021 at 16:18)</a>:</h4>
<p>and a prerequisite to that is switching to Chalk's type representation fully</p>



<a name="228067405"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Program%20slicing%20in%20RA/near/228067405" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vytautas Astrauskas [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Program.20slicing.20in.20RA.html#228067405">(Feb 27 2021 at 16:18)</a>:</h4>
<p>I see. Thanks!</p>



<a name="228067604"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Program%20slicing%20in%20RA/near/228067604" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Program.20slicing.20in.20RA.html#228067604">(Feb 27 2021 at 16:22)</a>:</h4>
<p><span class="user-mention silent" data-user-id="129457">Florian Diebold</span> <a href="#narrow/stream/185405-t-compiler.2Fwg-rls-2.2E0/topic/Program.20slicing.20in.20RA/near/228067400">said</a>:</p>
<blockquote>
<p>and a prerequisite to that is switching to Chalk's type representation fully</p>
</blockquote>
<p>Is there an incremental path to that? A part that somebody other than you could implement?</p>



<a name="228067620"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Program%20slicing%20in%20RA/near/228067620" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vytautas Astrauskas [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Program.20slicing.20in.20RA.html#228067620">(Feb 27 2021 at 16:22)</a>:</h4>
<p><span class="user-mention" data-user-id="265377">@Will Crichton</span> So, it seems that you will have to build on top of Rustc. If you are aiming for a research prototype, one option would be to hack something on top of <a href="https://github.com/viperproject/prusti-dev">Prusti</a>, which should have most of the information you need or at least some ideas how to get it.</p>



<a name="228068445"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Program%20slicing%20in%20RA/near/228068445" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Will Crichton <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Program.20slicing.20in.20RA.html#228068445">(Feb 27 2021 at 16:37)</a>:</h4>
<p><span class="user-mention silent" data-user-id="116109">Vytautas Astrauskas</span> What's the advantage of using Prusti vs. rustc_private? Are there more slicing-relevant analyses than in rustc? Or is the analysis information more conveniently accessed/ documented?</p>



<a name="228069017"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Program%20slicing%20in%20RA/near/228069017" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vytautas Astrauskas [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Program.20slicing.20in.20RA.html#228069017">(Feb 27 2021 at 16:47)</a>:</h4>
<p><span class="user-mention silent" data-user-id="265377">Will Crichton</span> <a href="#narrow/stream/185405-t-compiler.2Fwg-rls-2.2E0/topic/Program.20slicing.20in.20RA/near/228068445">said</a>:</p>
<blockquote>
<p><span class="user-mention silent" data-user-id="116109">Vytautas Astrauskas</span> What's the advantage of using Prusti vs. rustc_private? Are there more slicing-relevant analyses than in rustc? Or is the analysis information more conveniently accessed/ documented?</p>
</blockquote>
<p>The borrow checker information is buried deep inside the Rustc and Prusti uses <a href="https://github.com/viperproject/prusti-dev/blob/e207038b94cb8e5499b309de7ec52765b6e2404b/prusti-interface/src/environment/borrowck/regions.rs#L25-L43">extremely ugly hacks</a> to get that information out. If you build on top of Prusti, you will not need to reimplement them. Of course, if you know a better way of getting out the borrow information, then I would be super happy to hear that because maintaining this code is a pain.</p>



<a name="228069744"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Program%20slicing%20in%20RA/near/228069744" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vytautas Astrauskas [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Program.20slicing.20in.20RA.html#228069744">(Feb 27 2021 at 17:00)</a>:</h4>
<p><span class="user-mention" data-user-id="265377">@Will Crichton</span> If you would like to have a call to discuss what Prusti does and whether/how that could be useful for you, let me know.</p>



<a name="228081108"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Program%20slicing%20in%20RA/near/228081108" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Program.20slicing.20in.20RA.html#228081108">(Feb 27 2021 at 20:29)</a>:</h4>
<p><span class="user-mention silent" data-user-id="203546">Laurențiu Nicola</span> <a href="#narrow/stream/185405-t-compiler.2Fwg-rls-2.2E0/topic/Program.20slicing.20in.20RA/near/228067604">said</a>:</p>
<blockquote>
<p><span class="user-mention silent" data-user-id="129457">Florian Diebold</span> <a href="#narrow/stream/185405-t-compiler.2Fwg-rls-2.2E0/topic/Program.20slicing.20in.20RA/near/228067400">said</a>:</p>
<blockquote>
<p>and a prerequisite to that is switching to Chalk's type representation fully</p>
</blockquote>
<p>Is there an incremental path to that? A part that somebody other than you could implement?</p>
</blockquote>
<p>Hmm actually I think the best approach is to gradually move the API of things like <code>Ty</code> to be the same as the Chalk version, to reduce the size of the final step of actually switching</p>



<a name="228094505"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Program%20slicing%20in%20RA/near/228094505" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lukas Wirth <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Program.20slicing.20in.20RA.html#228094505">(Feb 28 2021 at 00:57)</a>:</h4>
<p>I'll try to work on that a bit</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>